<!-- 上传图片控件 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header table-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="myModalLabel" class="modal-title">上传文件</h3>
            </div>
            <div class="modal-body">
                <form id="upload_image_form" method="POST" enctype="multipart/form-data" action="/admin/upload/single/" target="upload_image_iframe">
                    <input name="i" type="hidden" id="upload_image_form_i" />
                    <input name="upload_image_file" type="file" class="input-xlarge" />
                </form>
            </div>
            <div class="modal-footer modal-">
                <button data-dismiss="modal" class="btn btn-danger pull-left">取消</button>
                <button class="btn btn-info" data-dismiss="modal" onclick="document.getElementById('upload_image_form').submit();">开始上传</button>
            </div>
            <iframe id="upload_image_iframe" name="upload_image_iframe" width="0" height="0" frameborder="0" scrolling="no" src=""></iframe> 
        </div>
    </div>
</div>

<script type="text/javascript">
    var resourcesHost = "<?php echo isset($resourcesHost) ? $resourcesHost : '' ?>";
    //class为upload_image的文本框获取上传控件
    $('.upload_image').each(function () {
        var self = this;
        $(this).uploadModal({
            obj: self,
            success: function (data) {
                if (data.status == 1) {
                    $(self).val(resourcesHost + data.dest_file_name);
                    $("input#name").val(data.name);
                    $("select#type").val(data.type);
                } else {
                    alert(data.error_message);
                }
            }
        })
    });
</script>
</body>
</html>